<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('客户列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="operlog-form">
                <div class="select-list">
                    <ul>
                        <li>
                            执行类型：<select name="type">
                                <option value="">所有</option>
                                <option value="发货人">发货人</option>
                                <option value="收货人">收货人</option>
                            </select>
                        </li>
                        <li>
                            创建人：<input type="text" name="createBy"/>
                        </li>
                        <li>
                            客户名称：<input type="text" name="name"/>
                        </li>
                        <li>
                            客户联系方式：<input type="text" name="phone"/>
                        </li>
                        <li>
                            客户地址：<input type="text" name="addressLine2"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="searchPre()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="add()" shiro:hasPermission="business:customer:add">
                <i class="fa fa-plus"></i> 新增
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('business:customer:edit')}]];
    var removeFlag = [[${@permission.hasPermi('business:customer:remove')}]];
    var prefix = ctx + "business/customer";

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add/{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            modalName: "客户",
            queryParams: queryParams,
            columns: [{
                checkbox: true
            },{
                title: "序号",
                formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
            },
                {
                    field: 'name',
                    title: '客户名称',
                    align: "center"
                },
                {
                    field: 'email',
                    title: '邮箱',
                    align: "center"
                },
                {
                    field: 'phone',
                    title: '联系方式',
                    align: "center"
                },
                {
                    field: 'addressLine1',
                    title: '地址',
                    align: "center"
                },
                {
                    field: 'addressLine2',
                    title: '详细地址',
                    align: "center"
                },
                {
                    field: 'type',
                    title: '类型',
                    align: "center"
                },
                {
                    field: 'createBy',
                    title: '创建人',
                    align: "center"
                },{
                    field: 'createTime',
                    title: '创建时间',
                    align: "center"
                }, {
                    field: 'updateBy',
                    title: '修改人',
                    align: "center"
                },{
                    field: 'updateTime',
                    title: '修改时间',
                    align: "center"
                },{
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    function queryParams(params) {
        var search = $.table.queryParams(params);
        return search;
    }

    function searchPre() {
        $.table.search('operlog-form', 'bootstrap-table');
    }

    function resetPre() {
        $("#operlog-form")[0].reset();
        $.table.search('operlog-form', 'bootstrap-table');
    }

    function add() {
        $.operate.add();
    }

</script>
</body>
</html>
